package org.springblade.common.exception;


import lombok.Data;
import org.springframework.http.HttpStatus;

/**
 * @author wukq
 * @create 2024/4/9 16:46
 */
@Data
public class MyServiceException extends RuntimeException {
	private static final long serialVersionUID = 2359767895161832954L;
	private final ResultCode resultCode;


	public MyServiceException(String message) {
		super(message);
		this.resultCode = ResultCode.FAILURE;
	}

	public MyServiceException(ResultCode resultCode) {
		super(resultCode.getMessage());
		this.resultCode = resultCode;
	}

	public MyServiceException(ResultCode resultCode, String deviceType) {
		super(DeviceTypeEnum.MOBILE.getKey().equals(deviceType) ? resultCode.getH5msg() : resultCode.getMessage());
		this.resultCode = resultCode;
	}

	public MyServiceException(ResultCode resultCode, Throwable cause, HttpStatus httpStatus) {
		super(cause);
		this.resultCode = resultCode;
	}

	public Throwable fillInStackTrace() {
		return this;
	}

	public Throwable doFillInStackTrace() {
		return super.fillInStackTrace();
	}

	public ResultCode getResultCode() {
		return this.resultCode;
	}


}
